package kisti.gui.Demo;

import java.io.BufferedWriter;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.Socket;



/**
 * <pre>
 * daniel.kisti.Helper
 *   |_ RequestDataToTierServer.java
 *
 * </pre>
 *
 * Desc :
 * @Company : KISTI
 * @Author :daniel
 * @Date   :2011. 11. 14. 오후 4:49:24
 * @Version: V2
 *
 */
public class RequestDataToTierServerForDemo {

	
	private static final String IPADDR = "150.183.234.151";
	private static final int PORT = 8197;
	
	
	public RequestDataToTierServerForDemo() {
		// TODO Auto-generated constructor stub
	}
	/**
	 * 
	 * Desc : Tier와 통신하는 소켓 클래스 
	 * @Method Name : request
	 * @param serviceName
	 * @return obj : 요청 결과를 xml 형태로 가져와 obj 형태로 리턴
	 *
	 */
	public void request(String serviceName) {
		// TODO Auto-generated method stub
		Object obj = null;
		
		try {
			InetAddress serverAddr = InetAddress.getByName(IPADDR);			
			Socket socket = new Socket(IPADDR, PORT);
			
			try {				
				//요청
				PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()),8192  ),true);
				out.println(serviceName);
				//데이터 접수
//				ObjectInputStream ois = new ObjectInputStream(socket.getInputStream());				
				//object 에 저장				
//				obj = ois.readObject();


			} catch (Exception e) {				// TODO: handle exception
				System.out.println(e.toString());
				e.printStackTrace();
				
			}finally{				socket.close();			}
		} catch (Exception e) {
			// TODO: handle exception			
			e.printStackTrace();
			System.out.println(e.toString());
		}		
//		return obj;
	}

	
	/**
	 * Desc :
	 * @Method Name : main
	 * @param args
	 * 
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}
}


